home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Paint Shop Pro / PSP900enTR.exe / Data1.cab / _706B111540B541299224257330FAE7BC < prev    next >
Encoding:
Text File  |  2004-08-16  |  5.4 KB  |  126 lines

  1. from JascApp import *
  2. import JascUtils
  3.  
  4. def ScriptProperties():
  5.     return {
  6.         'Author': u'Jasc Software, Inc.',
  7.         'Copyright': u'Copyright (c) 2002-2004 Jasc Software, Inc.  All rights reserved.',
  8.         'Description': "The the current image and split to RGB, putting the separate channels back as layers in a layer group.",
  9.         'Host': u'Paint Shop Pro',
  10.         'Host Version': u'8.00'
  11.         }
  12.  
  13. # Begin Translatable Strings
  14. Blue = "Blue"
  15. BlueChannel = "Blue Channel"
  16. Green = "Green"
  17. GreenChannel = "Green Channel"
  18. Red = "Red"
  19. RedChannel = "Red Channel"
  20. RGBChannels = "RGB Channels"
  21. # End Translatable Strings
  22.  
  23. def Do(Environment):
  24.     if JascUtils.RequireADoc( Environment ) == App.Constants.Boolean.false:
  25.         return
  26.     
  27.     # keep track of the doc we are starting with
  28.     TargetDoc = App.TargetDocument
  29.     
  30.     # start by splitting the current image.
  31.     App.Do( Environment, 'SplitToRGB', {
  32.             'GeneralSettings': {
  33.                 'ExecutionMode': App.Constants.ExecutionMode.Default, 
  34.                 'AutoActionMode': App.Constants.AutoActionMode.Match
  35.                 }
  36.             })
  37.  
  38.     # the split created 3 new documents and puts them at the end of the open list.
  39.     # make a three element list that we can reorder.  At this point we don't
  40.     # care about the contents, just that it has three elements
  41.     NewDocs = App.Documents[-3:]                # grab the last three docs
  42.           
  43.     # now loop over the three newest docs.
  44.     for ChannelDoc in App.Documents[-3:]:
  45.         Name = ChannelDoc.Title
  46.         if Name.find( Blue ) != -1:
  47.           NewDocs[0] = ChannelDoc # make Blue first
  48.         elif Name.find( Green ) != -1:
  49.           NewDocs[1] = ChannelDoc # make Green next
  50.         elif Name.find( Red ) != -1:
  51.           NewDocs[2] = ChannelDoc # make Red last
  52.             
  53.     
  54.     FirstChannel = App.Constants.Boolean.true   # need special handling on the first one
  55.     
  56.     # We use explicit specification of which document to work on by adding a fourth
  57.     # parameter to the App.Do call.  For operations on one of the single channel
  58.     # images we use one of the saved docs.  For operations on the original doc we use
  59.     # the saved TargetDoc.
  60.     for Doc in NewDocs:  
  61.         # this shouldn't be necessary, but at the moment paste as new layer has a bug,
  62.         # so we promote manually.  This assumes the original image is RGB.
  63.         App.Do( Environment, 'IncreaseColorsTo16Million', {}, Doc )
  64.         
  65.         # copy it to the clipboard        
  66.         App.Do( Environment, 'Copy', {}, Doc )
  67.         
  68.         # paste it into the existing document - note the specification of target doc
  69.         App.Do( Environment, 'PasteAsNewLayer', {}, TargetDoc )
  70.  
  71.         # when we pasted it the layer came in as Raster Layer n, and we want to know what
  72.         # channel it represents, so pick up the image title and use that to determine
  73.         # the layer name.  Out of split to RGB the image will be named RedN, GreenN, and BlueN.
  74.         NewLayerName = Doc.Title
  75.         if NewLayerName.find( Blue ) != -1:
  76.             NewLayerName = BlueChannel
  77.         elif NewLayerName.find( Green ) != -1:
  78.             NewLayerName = GreenChannel
  79.         else:
  80.             NewLayerName = RedChannel
  81.             
  82.         # now that we have the layer name, rename it
  83.         App.Do( Environment, 'LayerProperties', {
  84.                 'General': {
  85.                     'Name': NewLayerName, 
  86.                     }, 
  87.                 'GeneralSettings': {
  88.                     'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  89.                     'AutoActionMode': App.Constants.AutoActionMode.Default
  90.                     }
  91.                 }, TargetDoc )
  92.         
  93.         # we want the channels to end up inside of a layer group, so after we
  94.         # paste the first channel in create a layer group to hold it, and then select
  95.         # the layer inside the group so subsequent creates go where we want them.
  96.         if FirstChannel == App.Constants.Boolean.true:
  97.             FirstChannel = App.Constants.Boolean.false
  98.  
  99.             # create the layer group
  100.             App.Do( Environment, 'NewLayerGroup', {
  101.                     'General': {
  102.                         'Name': RGBChannels, 
  103.                         }, 
  104.                     'GeneralSettings': {
  105.                         'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  106.                         'AutoActionMode': App.Constants.AutoActionMode.Match
  107.                         }
  108.                     }, TargetDoc )
  109.  
  110.             # select the member of the group rather than the group itself            
  111.             NewLayer = App.Do( Environment, 'SelectLayer', {
  112.                     'Path': (0,0,[1],App.Constants.Boolean.false), 
  113.                     'GeneralSettings': {
  114.                         'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  115.                         'AutoActionMode': App.Constants.AutoActionMode.Default
  116.                         }
  117.                     }, TargetDoc)
  118.             
  119.         # do the close in silent mode since we don't want to save changes                
  120.         App.Do( Environment, 'FileClose', {
  121.                 'GeneralSettings': {
  122.                     'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  123.                     'AutoActionMode': App.Constants.AutoActionMode.Match
  124.                     }
  125.                 }, Doc )
  126.